package com.zmn.plat.admin.controller.contract.borrow.record;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.dubbo.config.annotation.Reference;
import com.zmn.common.constant.GlobalConsts;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
import com.zmn.mcc.common.constant.DpermitConsts;
import com.zmn.mcc.common.dto.dept.DeptDRO;
import com.zmn.mcc.dubbo.interfaces.dept.DeptListRemoteService;
import com.zmn.mcc.dubbo.interfaces.staff.StaffListRemoteService;
import com.zmn.plat.admin.controller.PlatBaseController;
import com.zmn.plat.dubbo.utils.DubboConsts;
import com.zmn.plat.services.interfaces.company.BaseCompanyService;
import com.zmn.plat.services.interfaces.contract.borrow.record.ContractBorrowRecordService;

/**
 * 合同借阅记录表
 *
 * @author linfeng
 * @since 2020-05-09 11:41:45
 */
public class ContractBorrowRecordBaseController extends PlatBaseController {
    protected Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource
    protected ContractBorrowRecordService contractBorrowRecordService;

    @Resource
    protected BaseCompanyService baseCompanyService;

    @Reference(version = DubboConsts.INTERFACE_VERSION, check = false)
    StaffListRemoteService staffListRemoteService;

    @Reference(version = DubboConsts.INTERFACE_VERSION, check = false)
    DeptListRemoteService deptListRemoteService;

    /**
     * 获取一级部门
     *
     * @return the one dept list
     */
    @ReadOnlyConnection
    protected List<DeptDRO> getOneDeptList() {
        ResponseDTO<List<DeptDRO>> data = deptListRemoteService.listDeptByLevelAndStatus(DpermitConsts.DEPT_LEVEL_ONE, GlobalConsts.YES);
        List<DeptDRO> oneDeptList = new ArrayList<>();
        if (data.isSuccess()) {
            oneDeptList = data.getData();
        }

        return oneDeptList;
    }

    /**
     * 获取二级部门
     *
     * @return the two dept list
     */
    @ReadOnlyConnection
    protected List<DeptDRO> getTwoDeptList() {
        ResponseDTO<List<DeptDRO>> data = deptListRemoteService.listDeptByLevelAndStatus(DpermitConsts.DEPT_LEVEL_TWO, GlobalConsts.YES);
        List<DeptDRO> twoDeptList = new ArrayList<>();
        if (data.isSuccess()) {
            twoDeptList = data.getData();
        }

        return twoDeptList;
    }
}
